package routers

import (
	auth "gxcvu-ai/app/controller/Auth"
	"gxcvu-ai/app/controller/audio"
	"gxcvu-ai/app/controller/chat"
	"gxcvu-ai/app/controller/market"
	"gxcvu-ai/app/controller/painting"
	"gxcvu-ai/app/middlewares"
	"net/http"

	"github.com/gin-gonic/gin"
)

func RegisterApiRouters(r *gin.Engine) {

	v1 := r.Group("/v1")
	{
		authGroup := v1.Group("/auth")
		{
			auc := new(auth.AuthController)
			// 用户登录
			authGroup.POST("/token", auc.Login)
			// 邮箱是否存在
			authGroup.POST("/email/exist", auc.SingupEmailExist)
			// 发送邮箱验证码
			authGroup.POST("/email/verify", auc.SingupEmailVerify)
			// 注册账户
			authGroup.POST("/register", auc.Register)
			// 刷新TOKEN
			authGroup.POST("/token/refresh", auc.RefreshToken)
		}

		chatGroup := v1.Group("/chat")
		{
			ctc := new(chat.ChatController)
			chatGroup.PATCH("", middlewares.AuthJWT(), ctc.Chat)
			chatGroup.POST("", middlewares.AuthJWT(), ctc.Create)
			chatGroup.POST("/info", middlewares.AuthJWT(), ctc.Get)
			chatGroup.GET("", middlewares.AuthJWT(), ctc.GetAllChat)
		}

		marketGroup := v1.Group("/market")
		{
			mkc := new(market.MarketController)
			marketGroup.GET("", middlewares.AuthJWT(), mkc.GetAllMarket)
		}

		paintingGroup := v1.Group("/painting")
		{
			pac := new(painting.PaintingController)
			paintingGroup.POST("", middlewares.AuthJWT(), pac.Create)
			paintingGroup.GET(":task_id", middlewares.AuthJWT(), pac.Get)
		}

		audioGroup := v1.Group("/audio")
		{
			auc := new(audio.AudioController)
			audioGroup.POST("", middlewares.AuthJWT(), auc.GetAudio)
		}

		v1.GET("/", func(c *gin.Context) {
			c.JSON(http.StatusOK, gin.H{
				"message": "Welcome to the API",
				"version": "1.0.0",
			})
		})
	}

}
